<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../../vue.js"></script>
  </head>

  <body>
    <div id="app">
      <h1>{{isHot?"热":"冷"}}</h1>
      <button @click="isHot=!isHot"></button>
    </div>
    <script>
      Vue.config.productionTip = false;
      //实例化Vue
      const vm = new Vue({
        el: "#app",
        data() {
          return {
            isHot: true,
          };
        },
      });

      //在vue实例vm上有一个$watch方法,也可以对vm实例上的属性进行监听

      vm.$watch("isHot",()=>{console.log("监听有更新了");},{immediate:true})
    </script>
  </body>
</html>
